<?php
namespace app\api\service\uniapp\goods;

use app\api\model\Region;
use app\api\model\ShopYiwu;
use app\api\model\UserStore;
use app\common\controller\Api;
use think\Db;

class Goods10 extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function get_goods($goodsid){
        if(empty($goodsid)){
            $this->error("参数错误");
        }
        $goods = ShopYiwu::where('id',$goodsid)->find();
        if(!$goods){
            $this->error("商品不存在");
        }
        //商品浏览加1
        ShopYiwu::where('id',$goodsid)->setInc('page_views');
        $goods['goods_pic'] = get_image($goods['main_pics']);
        $goods['countdown'] = calculateTimeDifference($goods['end_time']);
        $shop = UserStore::where('id',$goods['shop_id'])->find();
        $shop['shop_img'] = config('img_url').str_replace('/public','',$shop['store_img'][0]);;
        $goods['shop'] = $shop;
        $this->success("加载成功",$goods);
    }
}